package com.fakeDYChat.common.common.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private final TokenInterceptor tokenInterceptor;
    private final CollectorInterceptor collectorInterceptor;
    private final UserBlackInterceptor userBlackInterceptor;

    public InterceptorConfig(TokenInterceptor tokenInterceptor,
                             CollectorInterceptor collectorInterceptor,
                             UserBlackInterceptor userBlackInterceptor) {
        this.tokenInterceptor = tokenInterceptor;
        this.collectorInterceptor = collectorInterceptor;
        this.userBlackInterceptor = userBlackInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/capi/**");
        registry.addInterceptor(collectorInterceptor)
                .addPathPatterns("/capi/**");
        registry.addInterceptor(userBlackInterceptor)
                .addPathPatterns("/capi/**");
    }
}
